import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;

import javax.imageio.*;
import javax.swing.*;

public class GenImageLibras {
	
	static final int N = 945;
	static final int Q = 1;
	static final int scale = 50;
	
	public static void main(String[] args) throws Exception {
		Scanner scanner = new Scanner(new File("in.txt"));
		PrintStream printStream = new PrintStream(new File("libras-long.sds"));
		System.setOut(printStream);
		
		int cluster[] = new int[N];
		double x[][] = new double[N][45];
		double y[][] = new double[N][45];
		
		for(int it = 0; it < N; it++) {
			// data
			String pieces[] = scanner.nextLine().split(",");
			
			// to draw
			BufferedImage image = new BufferedImage(scale,scale,BufferedImage.TYPE_INT_RGB);
			Graphics graphics = image.getGraphics();
			graphics.setColor(Color.WHITE);
			graphics.fillRect(0, 0, scale, scale);
			graphics.setColor(Color.BLACK);
			
			// get data
			for(int i = 0; i < 45; i++) {
				x[it][i] = Double.parseDouble(pieces[2*i]);
				y[it][i] = Double.parseDouble(pieces[2*i+1]);
				int xp = (int)(x[it][i]*scale), yp = (int)(y[it][i]*scale);
				//graphics.drawLine(xp,yp,xp,yp);
				graphics.fillOval(xp, yp, 5, 5);
			}
			
			cluster[it] = Integer.parseInt(pieces[90]);
			
			String id = "" + (it+1);
			while(id.length() < 3) id = "0"+id;
			File outputfile = new File("img/libras" + id + ".png");
			ImageIO.write(image, "png", outputfile);
		}
		
		/*
		// generate file
		System.out.println("RECTANGLE_MATRIX = (");
		for(int it = 0; it < N; it++) {
			System.out.print("(" + cluster[it]);
			for(int i = 0; i < 45; i++) {
				double xp = x[it][i], yp = y[it][i], xq = x[it][Math.min(i+1,44)], yq = y[it][Math.min(i+1,44)];
				double ix = (xq - xp) / Q, iy = (yq - yp) / Q;
				for(int j = 0; j < Q; j++) {
					System.out.printf(",(%.4f : %.4f)", xp, xp);
					System.out.printf(",(%.4f : %.4f)", yp, yp);
					xp += ix;
					yp += iy;
				}
			}	
			System.out.print(")");
			if(it+1 != N) System.out.print(",");
			System.out.println();
		}
		System.out.println(")");
		*/
		
	}
}